<?php
/**
 * Created by IntelliJ IDEA.
 * User: xmiao
 * Date: 2018/12/11
 * Time: 11:58
 */
namespace app\magic\controller\admin;
use \app\magic\service\admin\IndexService;
class Index extends Base
{
    /*
     * 定义indexService
     */
    private $indexService = null;
    /**
     * 首页
     */
    public function index(){
        return $this->fetch();
    }

    /**
     * 验证登录
     */
    public function chkLogin(){
        $data=input('post.');
        $this->indexService = new IndexService();//实例化IndexService
        switch ($this->indexService->chkLogin($data)){
            case "true":
                return "success";
                black;
            case "false":
                return "error";
                black;
            default:
                return "非法请求";
                black;
        }
    }

    /**
     * 退出登录
     */
    public function outLogin(){
        session('uid',null);
        session('uname',null);
        echo '<script>location.href="/admin";</script>';
    }
}